<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<input type="file" name="file" id="file1">


<button id="browseButton">浏览文件</button>

<button id="upload" onclick="uploader.upload()">上传</button>


<script src="jquery-1.12.4.min.js"></script>
<script src="uploader/uploader.min.js"></script>
<script src="ajaxfileupload.js"></script>
<script>

    var jwt = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1OTIxMjU3MzUsImFwcCI6InRlc3QifQ.dkMuk38IKhZKjbJ56mlGpQH4izeCIkKgB3bEvKJTA8w";
    $("#file1").change(function () {
        $.ajaxFileUpload({
            fileElementId: 'file1',
            url: 'http://localhost:6001/upload',
            dataType: 'text',
            //
            success: function (data) {
                console.log("上传成功：", data);
            },
            data: {
                "jwt": jwt
            }
        });
    });


    var uploader = new Uploader({
        target: 'http://localhost:6001/chunkupload',
        headers: {jwt: jwt}
    });

    uploader.assignBrowse(document.getElementById('browseButton'));


    //uploader.assignBrowse(document.getElementById('folderButton'), true);

    //
    // 文件添加 单个文件
    uploader.on('fileAdded', function (file, event) {
        console.log("fileAdded:", file, event)
    });
    // 单个文件上传成功
    uploader.on('fileSuccess', function (rootFile, file, message) {

        console.log("fileSuccess：", rootFile, file, message)
    });
    // 根下的单个文件（文件夹）上传完成
    uploader.on('fileComplete', function (rootFile) {

        console.log("fileComplete:", rootFile)
    });
    // 某个文件上传失败了
    uploader.on('fileError', function (rootFile, file, message) {
        console.log("fileError:", rootFile, file, message)
    });

</script>
</body>
</html>